package com.yl.applicationsecurity.utils;

/**
 * @author 鹤仙问鹿仙
 * @program: Application-security
 * @description:
 * @date 2025-05-27 20:06:03
 */
public class ScoreCalculatorUtil {

    /**
     * 根据分子和分母计算得分
     * @param numerator 分子
     * @param denominator 分母
     * @return 得分
     */
    public static int calculateScore(int numerator, int denominator) {
        if (denominator <= 0) {
            return 100;
        }

        double percentage = 100 -(numerator * 100.0) / denominator;

        if (percentage >= 95) return 100;
        else if (percentage >= 90) return 90;
        else if (percentage >= 85) return 80;
        else if (percentage >= 80) return 70;
        else if (percentage >= 75) return 60;
        else if (percentage >= 70) return 50;
        else if (percentage >= 65) return 40;
        else if (percentage >= 60) return 30;
        else if (percentage >= 55) return 20;
        else if (percentage >= 50) return 10;
        else return 0;
    }

    // 示例
    public static void main(String[] args) {
        System.out.println(calculateScore(95, 100)); // 输出: 100
        System.out.println(calculateScore(88, 100)); // 输出: 80
        System.out.println(calculateScore(63, 100)); // 输出: 30
    }

}

